package com.yonyou.minio.demo;

import io.minio.*;
import io.minio.errors.MinioException;

/**
 * @Author wwj
 * @Date 2021/12/14
 * @Description 文件下载
 */
public class FileDownload {

    public static void main(String[] args) throws Exception{

        // 1 创建mc
        MinioClient minioClient = MinioClient.builder()
                .endpoint("http://10.6.174.190:9000")
                .credentials("minioadmin", "minioadmin")
                .build();
        
        // 2 下载文件
        try {
            minioClient.downloadObject(
                    DownloadObjectArgs.builder()
                            .bucket("bucket01")
                            .object("test.jpg")
                            .filename("E:/test.jpg")
                            .build());

            System.out.println("下载文件成功！");
        } catch (MinioException e) {
            System.out.println("Error occurred :" + e);
            System.out.println("HTTP trace :" + e.httpTrace());
        }
    }
}
